function toRegister() {
    let username = document.getElementById("user").value;
    let email = document.getElementById("email").value;
    let phone = document.getElementById("phone").value;
    let password = document.getElementById("password").value;
    let passwordVerification = document.getElementById("passwordVerification").value;

        if (username === "" || password === "" || passwordVerification === "" || email === "" || phone === "") {
            alert("存在任意的结果为空字符，请检查输入是否正确");
            return;
        }
        if (password !== passwordVerification) {
            alert("密码输入不匹配，请重新输入");
            return;
        }
        if (!VerificationEmail(email)) {
            alert("错误的邮件格式");
            return;
        }if (!VerificationPassword(password)) {
            alert("错误的密码格式，密码应当包含大小写字符以及数字和至少一个特殊字符(!@#$%^&*)，且长度为8~20个字符");
            return;
        }
        const xhr = new XMLHttpRequest();
        xhr.open("post", "./register", true);
        xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xhr.responseType = "json";
        xhr.send("users=" + username + "&email=" + email + "&password=" + password + "&phone=" + phone);
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4 && xhr.status === 200) {
                alert("注册成功,请登录");
                window.location.href="/blocks_war_exploded/login.jsp";
            } else {
                alert("注册系统正在被维护，请等待");
            }
        }

}
function VerificationEmail(email) {
    const verificationEmail = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
    return verificationEmail.test(email);
}
function VerificationPassword(password) {
    const verificationPassword = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*]).{8,20}$/;
    return verificationPassword.test(password);
}